{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {
    "collapsed": true
   },
   "source": [
    "### This is Example 4.3. Gambler’s Problem from Sutton's book.\n",
    "\n",
    "A gambler has the opportunity to make bets on the outcomes of a sequence of coin flips. \n",
    "If the coin comes up heads, he wins as many dollars as he has staked on that flip; \n",
    "if it is tails, he loses his stake. The game ends when the gambler wins by reaching his goal of $100, \n",
    "or loses by running out of money. \n",
    "\n",
    "On each flip, the gambler must decide what portion of his capital to stake, in integer numbers of dollars. \n",
    "This problem can be formulated as an undiscounted, episodic, finite MDP. \n",
    "\n",
    "The state is the gambler’s capital, s ∈ {1, 2, . . . , 99}.\n",
    "The actions are stakes, a ∈ {0, 1, . . . , min(s, 100 − s)}. \n",
    "The reward is zero on all transitions except those on which the gambler reaches his goal, when it is +1.\n",
    "\n",
    "The state-value function then gives the probability of winning from each state. A policy is a mapping from levels of capital to stakes. The optimal policy maximizes the probability of reaching the goal. Let p_h denote the probability of the coin coming up heads. If p_h is known, then the entire problem is known and it can be solved, for instance, by value iteration.\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "import numpy as np\n",
    "import sys\n",
    "import matplotlib.pyplot as plt\n",
    "if \"../\" not in sys.path:\n",
    "  sys.path.append(\"../\") "
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "collapsed": true
   },
   "source": [
    "\n",
    "### Exercise 4.9 (programming)\n",
    "\n",
    "Implement value iteration for the gambler’s problem and solve it for p_h = 0.25 and p_h = 0.55."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "def value_iteration_for_gamblers(p_h, theta=0.0001, discount_factor=1.0):\n",
    "    \"\"\"\n",
    "    Args:\n",
    "        p_h: Probability of the coin coming up heads\n",
    "    \"\"\"\n",
    "    # The reward is zero on all transitions except those on which the gambler reaches his goal,\n",
    "    # when it is +1.\n",
    "    rewards = np.zeros(101)\n",
    "    rewards[100] = 1 \n",
    "    \n",
    "    # We introduce two dummy states corresponding to termination with capital of 0 and 100\n",
    "    V = np.zeros(101)\n",
    "    \n",
    "    def one_step_lookahead(s, V, rewards):\n",
    "        \"\"\"\n",
    "        Helper function to calculate the value for all action in a given state.\n",
    "        \n",
    "        Args:\n",
    "            s: The gambler’s capital. Integer.\n",
    "            V: The vector that contains values at each state. \n",
    "            rewards: The reward vector.\n",
    "                        \n",
    "        Returns:\n",
    "            A vector containing the expected value of each action. \n",
    "            Its length equals to the number of actions.\n",
    "        \"\"\"\n",
    "        A = np.zeros(101)\n",
    "        stakes = range(1, min(s, 100-s)+1) # Your minimum bet is 1, maximum bet is min(s, 100-s).\n",
    "        for a in stakes:\n",
    "            # rewards[s+a], rewards[s-a] are immediate rewards.\n",
    "            # V[s+a], V[s-a] are values of the next states.\n",
    "            # This is the core of the Bellman equation: The expected value of your action is \n",
    "            # the sum of immediate rewards and the value of the next state.\n",
    "            A[a] = p_h * (rewards[s+a] + V[s+a]*discount_factor) + (1-p_h) * (rewards[s-a] + V[s-a]*discount_factor)\n",
    "        return A\n",
    "    \n",
    "    while True:\n",
    "        # Stopping condition\n",
    "        delta = 0\n",
    "        # Update each state...\n",
    "        for s in range(1, 100):\n",
    "            # Do a one-step lookahead to find the best action\n",
    "            A = one_step_lookahead(s, V, rewards)\n",
    "            # print(s,A,V) # if you want to debug.\n",
    "            best_action_value = np.max(A)\n",
    "            # Calculate delta across all states seen so far\n",
    "            delta = max(delta, np.abs(best_action_value - V[s]))\n",
    "            # Update the value function. Ref: Sutton book eq. 4.10. \n",
    "            V[s] = best_action_value        \n",
    "        # Check if we can stop \n",
    "        if delta < theta:\n",
    "            break\n",
    "    \n",
    "    # Create a deterministic policy using the optimal value function\n",
    "    policy = np.zeros(100)\n",
    "    for s in range(1, 100):\n",
    "        # One step lookahead to find the best action for this state\n",
    "        A = one_step_lookahead(s, V, rewards)\n",
    "        best_action = np.argmax(A)\n",
    "        # Always take the best action\n",
    "        policy[s] = best_action\n",
    "    \n",
    "    return policy, V"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Optimized Policy:\n",
      "[ 0.  1.  2.  3.  4.  5.  6.  7.  8.  9. 10. 11. 12. 12. 11. 15. 16. 17.\n",
      " 18.  6. 20. 21.  3. 23. 24. 25.  1.  2.  3.  4.  5.  6.  7.  8.  9. 10.\n",
      " 11. 12. 38. 11. 10.  9. 42.  7. 44.  5. 46. 47. 48. 49. 50.  1.  2.  3.\n",
      "  4.  5.  6.  7.  8.  9. 10. 11. 12. 13. 11. 10.  9. 17.  7. 19.  5. 21.\n",
      " 22. 23. 24. 25.  1.  2.  3.  4.  5.  6.  7.  8.  9. 10. 11. 12. 12. 11.\n",
      " 10.  9.  8.  7.  6.  5.  4.  3.  2.  1.]\n",
      "\n",
      "Optimized Value Function:\n",
      "[0.00000000e+00 7.24792480e-05 2.89916992e-04 6.95257448e-04\n",
      " 1.16010383e-03 1.76906586e-03 2.78102979e-03 4.03504074e-03\n",
      " 4.66214120e-03 5.59997559e-03 7.08471239e-03 9.03964043e-03\n",
      " 1.11241192e-02 1.56793594e-02 1.61464431e-02 1.69517994e-02\n",
      " 1.86512806e-02 1.98249817e-02 2.24047303e-02 2.73845196e-02\n",
      " 2.83388495e-02 3.04937363e-02 3.61633897e-02 3.84953022e-02\n",
      " 4.44964767e-02 6.25000000e-02 6.27174377e-02 6.33700779e-02\n",
      " 6.45857723e-02 6.59966059e-02 6.78135343e-02 7.08430894e-02\n",
      " 7.46098323e-02 7.64884604e-02 7.93035477e-02 8.37541372e-02\n",
      " 8.96225423e-02 9.58723575e-02 1.09538078e-01 1.10939329e-01\n",
      " 1.13360151e-01 1.18457374e-01 1.21977661e-01 1.29716907e-01\n",
      " 1.44653559e-01 1.47520113e-01 1.53983246e-01 1.70990169e-01\n",
      " 1.77987434e-01 1.95990576e-01 2.50000000e-01 2.50217438e-01\n",
      " 2.50870078e-01 2.52085772e-01 2.53496606e-01 2.55313534e-01\n",
      " 2.58343089e-01 2.62109832e-01 2.63988460e-01 2.66803548e-01\n",
      " 2.71254137e-01 2.77122542e-01 2.83372357e-01 2.97038078e-01\n",
      " 2.98439329e-01 3.00860151e-01 3.05957374e-01 3.09477661e-01\n",
      " 3.17216907e-01 3.32153559e-01 3.35020113e-01 3.41483246e-01\n",
      " 3.58490169e-01 3.65487434e-01 3.83490576e-01 4.37500000e-01\n",
      " 4.38152558e-01 4.40122454e-01 4.43757317e-01 4.47991345e-01\n",
      " 4.53440603e-01 4.62529268e-01 4.73829497e-01 4.79468031e-01\n",
      " 4.87912680e-01 5.01265085e-01 5.18867627e-01 5.37617932e-01\n",
      " 5.78614419e-01 5.82817988e-01 5.90080452e-01 6.05372123e-01\n",
      " 6.15934510e-01 6.39150720e-01 6.83960814e-01 6.92560339e-01\n",
      " 7.11950883e-01 7.62970611e-01 7.83963162e-01 8.37972371e-01\n",
      " 0.00000000e+00]\n",
      "\n"
     ]
    }
   ],
   "source": [
    "policy, v = value_iteration_for_gamblers(0.25)\n",
    "\n",
    "print(\"Optimized Policy:\")\n",
    "print(policy)\n",
    "print(\"\")\n",
    "\n",
    "print(\"Optimized Value Function:\")\n",
    "print(v)\n",
    "print(\"\")"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Show your results graphically, as in Figure 4.3.\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAYUAAAEWCAYAAACJ0YulAAAABHNCSVQICAgIfAhkiAAAAAlwSFlz\nAAALEgAACxIB0t1+/AAAADl0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uIDIuMS4wLCBo\ndHRwOi8vbWF0cGxvdGxpYi5vcmcvpW3flQAAIABJREFUeJzt3Xd8HNW5//HPI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\nWigpiIhICyUFERFpoaQgIiItlBREQmY2zMweM7PVZrbUzJ4zs8n7sZy7mi+4aGbfifM9a8xsyL6u\nS6Sr6ZBUEVpO/HsLuN/d/xjOOwLIdvfXD2C5u9x9YBzl1hBc+XPb/q5LpCuopSASOAWob04IAO6+\nEFhgZi+Z2Xwze9/MLoDggoPhfQzuD69h/6SZZYavvWJmBWZ2O8HVPBea2cPha0+b2bzwfgDXJKCe\nIh1SUhAJzCC42mZrNcB/uPtRBInj12GrAmAKMMvdDwd2AtfGvtHdbwZ2u/sR4aU3AK5y96OBAuB6\nMxscQV1E9puSgkjHDPipmS0C/klwOYWDw9fWu/ub4fOHgI/Esbzrzew94B2Ci5hN6uJ4RQ5ISudF\nRPqFJfz7gmqxLgXygaPdvT7s+08PX2s9INfhAF14babTgePdvdrMXolZlkiPoJaCSOBfQJqZXd08\nw8yOAQ4huF9DvZmdEk43G2Nmx4fPLwHeaGO59eHlzAFygYowIUwluGWqSI+ipCACeHAY3n8AHwsP\nSV0C3Ao8BxSYWSFBq+GDmLctAy4Pu5byaPveuLOAReFA8/NASlj+RwRdSCI9ig5JFdkP4e1Onw1v\nHi/SZ6ilICIiLdRSEBGRFmopiIhICyUFERFpoaQgIiItlBRERKSFkoKIiLT4/4EmbUnRp+/0AAAA\nAElFTkSuQmCC\n",
      "text/plain": [
       "<matplotlib.figure.Figure at 0x1d9de122198>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "# Plotting Final Policy (action stake) vs State (Capital)\n",
    "\n",
    "# x axis values\n",
    "x = range(100)\n",
    "# corresponding y axis values\n",
    "y = v[:100]\n",
    " \n",
    "# plotting the points \n",
    "plt.plot(x, y)\n",
    " \n",
    "# naming the x axis\n",
    "plt.xlabel('Capital')\n",
    "# naming the y axis\n",
    "plt.ylabel('Value Estimates')\n",
    " \n",
    "# giving a title to the graph\n",
    "plt.title('Final Policy (action stake) vs State (Capital)')\n",
    " \n",
    "# function to show the plot\n",
    "plt.show()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAYIAAAEWCAYAAABrDZDcAAAABHNCSVQICAgIfAhkiAAAAAlwSFlz\nAAALEgAACxIB0t1+/AAAADl0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uIDIuMS4wLCBo\ndHRwOi8vbWF0cGxvdGxpYi5vcmcvpW3flQAAGoxJREFUeJzt3Xu8HGV9x/HP13AXQghJMJDEgA0X\naw2XIwWxlIu0SCmJBSkUMW3B9KJyEbWovFpQq9AqUK9tCmKK3CQg1xZJYyKlhUAihIsgCYgQE5MA\nCQEBTeDXP+Y5sBzO7pk9Z2f27M73/Xrta3dm5/KbmWR/53memedRRGBmZtX1pnYHYGZm7eVEYGZW\ncU4EZmYV50RgZlZxTgRmZhXnRGBmVnFOBDZsSTpB0q1DWH+BpJNbGVMT+x5S7H229bik97ZiWzXb\nPEjS8prpByUd1Mp9WOdwIrAhk/RnkhZJel7SSkn/Jek9Q91uRFwWEX9Qs5+Q9FtD3W6rSJqcYnq+\n5rUE3hh7gTF8R9Jv0r6fkTRX0u7NbicifjsiFhQQonUAJwIbEkkfBy4EvgjsAEwCvglMa2dcJRsV\nEVun19Q27P+fImJrYAKwGvhOG2KwDuZEYIMmaVvgc8BHIuLaiPhVRGyIiBsj4pNpmX0l3SFpXSot\nfF3SZjXbCEmnSHpM0lOS/lnSm9J3fy7p9vT5trTKkvTX759K2k7STZLWSFqbPk/IEfeOkl6UNLpm\n3l5p/5tK+i1JP5L0bJp31SDOzaux1xznX0tammL9hiSl794m6YeSnk77u0zSqGb3GREvAJcD70jb\n3VzShZJWpNeFkjavE++r1U+SRkj6jKRHJT0nabGkiSnmr/RZ70ZJpzUbqw0vTgQ2FPsDWwDfb7DM\ny8DpwJi0/KHA3/ZZ5v1AD7A3WUniL/tuJCIOTB+npr+8ryL793sJ8FayksiLwNcHCjoi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DMSJ9nANeXHVsRIuLTETEhIiaTXdMfRsQJwHzgmLRY1xxvr4j4JfCk\npN3SrEOBn9Cl1zl5AthP0lbp33nvMXf1tU7qXdcbgA+lu4f2A57trUIatIjo6hdwBPAI8Cjw2XbH\nU9AxvoesaHgfcG96HUFWbz4PWJreR7c71gKO/SDgpvR5F+AuYBlwNbB5u+Mr4Hj3BBala30dsF23\nX2fgHOBh4AHgUmDzbrvWwBVkbSAbyP7iP6nedSWrGvpG+k27n+yOqiHt311MmJlVXLdXDZmZ2QCc\nCMzMKs6JwMys4pwIzMwqzonAzKzinAis0iS9RdKVkh6V9BNJ/ylp10Fs56LeDg0lfSbnOo9LGtPs\nvsxazbePWmWlB5T+D5gdEf+a5u0JbBMR/zOE7T4fEVvnWO5xsnvAnxrsvsxawSUCq7KDgQ29SQAg\nIu4F7pE0T9KPJd0vaRpkHfqlcQBmp37g50jaKn23QFKPpHPJesq8V9Jl6bvrJC1OferPbMNxmjXk\nRGBV9g6yniz7egl4f0TsTZYsvpJKDwC7AbMi4p3AeuBva1eMiDOBFyNiz8i6vQD4y4jYB+gBTpG0\nfQHHYjZoTgRmbyTgi5LuA/6brIvfHdJ3T0bE/6bP3yXr3mMgp0haAtxJ1lnYlBbHazYkmwy8iFnX\nepDXOi6rdQIwFtgnIjakuvwt0nd9G9UaNrJJOoisB839I+IFSQtqtmU2LLhEYFX2Q2BzSR/unSHp\nXcBbycY72CDp4DTda5Kk/dPn44Hb+9nuhtQtOMC2wNqUBHYnG0rUbFhxIrDKiuyWufcDh6XbRx8E\nzgb+E+iRtIisdPBwzWoPATNStdFo+h8vdhZwX2osvgXYJC3/ebLqIbNhxbePmuWUhgG9KbJB1M26\nhksEZmYV5xKBmVnFuURgZlZxTgRmZhXnRGBmVnFOBGZmFedEYGZWcf8PGuEWwOrW2QgAAAAASUVO\nRK5CYII=\n",
      "text/plain": [
       "<matplotlib.figure.Figure at 0x1d9e016fe48>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "# Plotting Capital vs Final Policy\n",
    "\n",
    "# x axis values\n",
    "x = range(100)\n",
    "# corresponding y axis values\n",
    "y = policy\n",
    " \n",
    "# plotting the bars\n",
    "plt.bar(x, y, align='center', alpha=0.5)\n",
    " \n",
    "# naming the x axis\n",
    "plt.xlabel('Capital')\n",
    "# naming the y axis\n",
    "plt.ylabel('Final policy (stake)')\n",
    " \n",
    "# giving a title to the graph\n",
    "plt.title('Capital vs Final Policy')\n",
    " \n",
    "# function to show the plot\n",
    "plt.show()\n"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.6.3"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 1
}
